#!/usr/bin/python
import Renderer
import Doctype
from Prototypes import *;


class Body(Container,Tag,Renderable):
	def __init__(self):
		Container.__init__(self)
		Tag.__init__(self)
		self.tag="body"

	def render(self):
		self.render_tag(renderer)
		self.render_contained(renderer)
		self.render_close(renderer)

class Title(Tag,Renderable):
	def __init__(self, title=""):
		Tag.__init__(self)
		self.tag="title"
		self.text=title

	def render(self,renderer):
		self.render_tag(renderer)
		renderer.write_unsafe(self.text)
		self.render_close(renderer)

class Page(Container,Tag):
	def __init__(self):
		Container.__init__(self)
		Tag.__init__(self)
		self.renderer = Renderer.Renderer()
		self.doctype = Doctype.XHTML_11
		self.tag="html"
		self.head=list()
		self.title=None

	def render(self):
		self.renderer.start()
		self.renderer.write(self.doctype)
		self.render_tag(self.renderer)
		self.renderer.write("<head>")
		if(self.title != None):
			self.title.render(self.renderer)

		for item in self.head:
			self.renderer.write(item)
		self.renderer.write("</head>")

		self.render_contained(self.renderer)
		self.render_close(self.renderer)
		self.renderer.end()

